/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.api;

import com.github.lvyanyang.annotation.Authorize;
import com.github.lvyanyang.core.BaseController;
import com.github.lvyanyang.core.BoolResult;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.PageList;
import com.github.lvyanyang.core.XCI;
import com.xci.edu.core.entity.EduStudentTrainLog;
import com.xci.edu.core.filter.EduStudentTrainLogFilter;
import com.xci.edu.core.service.EduStudentTrainLogService;
import com.github.lvyanyang.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学员培训日志接口
 * @author 张谦 zhangqian@xci96716.com
 * @since 2020-11-25 09:35:56
 */
@Api(tags = "学员培训日志接口")
@Authorize
@RestController
@RequestMapping(value = "/api/core/eduStudentTrainLog", produces = Const.PROJSON)
public class EduStudentTrainLogApiController extends BaseController {
    /** 学员培训日志服务 */
    @Resource private EduStudentTrainLogService eduStudentTrainLogService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新建学员培训日志")
    @Authorize(code = "core.eduStudentTrainLog.insert")
    @PostMapping("/insert")
    public BoolResult insert(@RequestBody EduStudentTrainLog entity) {
        return eduStudentTrainLogService.insert(entity);
    }

    //@ApiOperationSupport(order = 2)
    //@ApiOperation(value = "检查学员培训日志主键是否存在")
    //@PostMapping(value = "/existById")
    //public BoolResult existById(@RequestBody IdBody body) {
    //    return BoolResult.success(eduStudentTrainLogService.existById(body.getId()));
    //}
    //@ApiOperationSupport(order = 3)
    //@ApiOperation(value = "检查学员培训日志名称是否存在")
    //@PostMapping(value = "/existByName")
    //public BoolResult existByName(@RequestBody NameExcludeIdBody body) {
    //    return BoolResult.success(eduStudentTrainLogService.existByName(body.getName(), body.getExcludeId()));
    //}

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查询学员培训日志分页列表")
    @Authorize(code = "core.eduStudentTrainLog.select")
    @PostMapping("/selectPageList")
    public BoolResult<PageList<EduStudentTrainLog>> selectPageList(@RequestBody EduStudentTrainLogFilter filter) {
        return BoolResult.success(eduStudentTrainLogService.selectPageList(filter));
    }

    @ApiOperationSupport(order = 5, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "查询学员培训日志列表")
    @Authorize(code = "core.eduStudentTrainLog.select")
    @PostMapping("/selectList")
    public BoolResult<List<EduStudentTrainLog>> selectList(@RequestBody EduStudentTrainLogFilter filter) {
        return BoolResult.success(eduStudentTrainLogService.selectList(filter));
    }

    @ApiOperationSupport(order = 6, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "导出学员培训日志列表")
    @Authorize(code = "core.eduStudentTrainLog.export")
    @PostMapping(value = "/export", produces = {Const.PROOCTET, Const.PROJSON})
    public void export(@RequestBody EduStudentTrainLogFilter filter) {
        XCI.exportExcel(eduStudentTrainLogService.selectList(filter), EduStudentTrainLog.class, "学员培训日志列表");
    }

    //@ApiOperationSupport(order = 7)
    //@ApiOperation(value = "获取学员培训日志导出字段")
    //@PostMapping(value = "/exportNames")
    //public BoolResult<List<String>> exportNames() {
    //    return BoolResult.success(XCI.getExcelFiledNames(EduStudentTrainLog.class));
    //}
}